import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { URL, fileURLToPath } from 'node:url'
import createProxy from   './src/proxy/index.js'

// https://vite.dev/config/
export default defineConfig( async ({mode,command})=>{
  const proxyConfig = await createProxy(mode)
  return {
    plugins: [vue()],
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url)),
      },
    },
    esbuild: {
      drop: mode === 'production' ? ['console', 'debugger'] : []
    },
    server:{
      open: true,
      host:true,
      proxy:proxyConfig,
    }
  }
})
